<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>FE - react - base</title>
  <script src="https://unpkg.com/react@17/umd/react.development.js"></script>
  <script src="https://unpkg.com/react-dom@17/umd/react-dom.development.js"></script>
  <script src="https://cdn.staticfile.org/babel-standalone/6.26.0/babel.min.js"></script>
</head>
<body>
  
  <p>FE - react - 类式组件</p>
  <p>适用复杂组件定义</p>

  <div id="example"></div>

  <script type="text/babel">
    // 创建一个 person 类
    class Person {
      // 构造器方法
      constructor(name, age){
        // this 指向实例对象
        this.name = name 
        this.age = age
      }
      // 一般方法 , 放在类的原型对象上，供实例使用
      speak(){
        console.log(`我叫${this.name}`)
      }
    }

    // 实例两个对象    
    const p1 = new Person('tom', 18)
    const p2 = new Person('jerry', 20)

    // 创建学生继承
    class Student extends Person{
      // 构造器
      constructor(name,age,grade){
        super(name,age)
        this.grade = grade
      }
      //重写从父类继承过来的方法
      speak(){
        console.log(`我叫${this.name},我的年级${this.grade}`)
      }
    }
    const s1 = new Student();
    s1.speak();

    // 渲染函数式组件到页面
    // ReactDom.render(<MyComponent/>, document.getElementById('example'))

    /*
      S-1
      
    */

    /*
      S-2

  </script>

</body>
</html>